<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1">
  <title>注册</title>

  <!-- Set render engine for 360 browser -->
  <meta name="renderer" content="webkit">

  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp"/>

  <link rel="icon" type="image/png" href="images/favicon.png">

  <script src="../public/all/js/jquery-3.1.1.min.js"></script>
  <script src="../public/all/js/amazeui.min.js"></script>
  <script src="../public/all/js/jquery.cookie.js"></script>
  <script src="js/login.min.js"></script>
  
  <!-- debug only -->
  <script src="../public/all/js/jquery.nivo.slider.js"></script>
  <script src="../public/all/js/context.js"></script>
  <script src="../public/all/js/util.js"></script>
  <script src="../public/all/js/cmd.js"></script>
  <script src="js/app.js"></script>
  <script src="../public/all/js/classify.js"></script>
  <script src="../public/all/js/page.js"></script>
  <script src="../public/all/js/rule/rule.js"></script>

  <script src="../public/all/js/me.js"></script>
  <!-- debug only end -->
 
  <link rel="stylesheet" href="../public/all/css/amazeui.min.css">
  <link rel="stylesheet" href="css/remodal.min.css"> 
  <link rel="stylesheet" href="css/core.css"> 
  <link rel="stylesheet" href="css/register.css"> 
</head>
<body>
    <div class="container">
        <div class="logo"></div>
        <div class="regbox-wrap">
            <div class="regbox">
                <form onsubmit="return false;">
                    <div class="user-info">
                        <div class="tit">注册账号</div>
                        <div class="info-main">
                            <div id="recoTr">
                                <span class="cover">推荐人账号：</span>
                                <input type="text" id="regRecoUserName">
                                <span class="hint">上级代理账号或推荐人账号，如没有可以不填</span>
                            </div>
                            <div>
                                <span class="cover"><span class="cf40">*</span>会员账号：</span>
                                <input type="text" id="regUsername" maxlength="15">
                                <span class="hint">账号规则：账号必须为6-15位字母和数字组合</span>
                            </div>
                            <div>
                                <span class="cover"><span class="cf40">*</span>登录密码：</span>
                                <input type="password" id="regPassword" maxlength="20">
                                <span class="hint">密码规则：密码必须为6-20位字母和数字组合</span>
                            </div>
                            <div>
                                <span class="cover"><span class="cf40">*</span>确认密码：</span>
                                <input type="password" id="password1" maxlength="20">
                                <span class="hint">确认您的登录密码，请输入和以上一致的密码</span>
                            </div>
                            <div>
                                <span class="cover"><span class="cf40">*</span>真实姓名：</span>
                                <input type="text" id="fullName" maxlength="10">
                                <span class="hint cf40">真实姓名必须与您用于提款银行账户名称一致</span>
                            </div>
                            <div class="drawcode">
                                <span class="cover"><span class="cf40">*</span>取款密码：</span>
                                <select id="pwd1">
                                    <option value="0">0</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7">7</option>
                                    <option value="8">8</option>
                                    <option value="9">9</option>
                                </select>
                                <select id="pwd2">
                                    <option value="0">0</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7">7</option>
                                    <option value="8">8</option>
                                    <option value="9">9</option>
                                </select>
                                <select id="pwd3">
                                    <option value="0">0</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7">7</option>
                                    <option value="8">8</option>
                                    <option value="9">9</option>
                                </select>
                                <select id="pwd4">
                                    <option value="0">0</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7">7</option>
                                    <option value="8">8</option>
                                    <option value="9">9</option>
                                </select>
                                <span class="hint cf40">取款必须认证，务必记住</span>
                            </div>
                            <div class="hide" id="showRegEmail" style="display: block;">
                                <span class="cover"><span class="cf40">*</span>电子邮箱：</span>
                                <input type="text" id="email" maxlength="30">
                                <span class="hint">电子邮箱(Email)格式：88888888@qq.com</span>
                            </div>
                            
                            <div class="auth">
                                <span class="cover"><span class="cf40">*</span>验&nbsp;证&nbsp;码：</span>
                                <input type="text" id="valiCode">
                                <img class="imgCode" alt="看不清？点击更换一张验证图片" src="/api/getValidateCode.do?=0.838864016916578">
                            </div>
                        </div>
                    </div>
                    <div class="user-ctrl">
                        <div class="rulescheck">
                            <label for="rules_Check">
                                <input type="checkbox" id="rules_Check" checked="checked"><span>我已届满18岁合法博彩年龄﹐且同意各项开户条约。</span>
                            </label>
                        </div>
                        <div class="btns">
                            <input class="btn" type="submit" value="立即提交">
                            <input class="btn" type="reset" value="重新填写">
                            <input class="btn" type="button" value="返回首页">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- 提示框 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="clue">
        <div class="am-modal-dialog">
            <div class="border">
                <div class="am-modal-bd" id="clue_content"></div>
                <a href="javascript: void(0)" data-am-modal-close><button class="btn">关闭</button></a>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    $("input.btn[type='submit']").click(function() {
        // 提交注册
        var referee = $("#regRecoUserName").val().trim();
        var account = $("#regUsername").val().trim();
        var p1 = $("#regPassword").val().trim();
        var p2 = $("#password1").val().trim();
        var name = $("#fullName").val().trim();
        var p3 = $("#pwd1").val() + $("#pwd2").val() + $("#pwd3").val() + $("#pwd4").val();
        var email = $("#email").val().trim();
        var code = $("#valiCode").val().trim();

        if (account == "") {
            alert2("账号名称不能为空");
            $("#regUsername").focus();
            return;
        }
        if (! /^[0-9a-zA-Z]{6,15}$/.test(account)) {
            alert2("用户名6~15位数字或字母");
            $("#regUsername").focus();
            return;
        }
        if (!p1) {
            alert2("密码不能为空");
            $("#regPassword").focus();
            return;
        }
        if (p1.length > 20) {
            alert2("密码不能大于20个字符。");
            $("#regPassword").focus();
            return;
        }
        if (p1.length < 6) {
            alert2("密码不能小于6个字符。");
            $("#regPassword").focus();
            return;
        }
        if (p1 != p2) {
            alert2("输入的密码不一致，请重新输入。");
            $("#password1").focus();
            return;
        }

        if (!name) {
            aler2("真实姓名不能为空");
            $("#fullName").focus();
            return;
        }
        if (!/^[\u4E00-\u9FA5]{2,8}$/.test(name)) {
            alert2("请输入正确的真实姓名");
            $("#fullName").focus();
            return;
        }
        if (!email) {
            alert2("电子邮箱不能为空");
            $("#email").focus();
            return;
        }
        if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email)) {
            alert2("您的电子邮件格式不正确");
            $("#email").focus();
            return;
        }

        if ($("#tycbx").length && !$("#tycbx").is(":checked")) {
            alert2("未同意开户条约");
            return;
        }

        alert2("注册信息提交中...");
        urlInfo.params.try = 0;
        CMD.register(account, p1, name, "", referee, "pc", function(r) {
            CMD.modify_user_info(null, {
                tpassword: p3,
                email2: email,
            }, function() {
                Util.jumpUrl({
                    file: "agreement.html"
                });
            });
        }, function(r) {
            closeAlert();
            if (r) alert2("注册失败，原因：" + r);
            else alert2("注册失败！");

            // TODO: 刷新验证码
        })
    });

    $(".btns .btn[type='button'").click(function() {
        Util.jumpUrl({
            file: "index.html"
        });
    });

    // 代理填充进去
    if (urlInfo.params.referee) {
        $("#regRecoUserName").val(urlInfo.params.referee);
    }
</script>